/**
 * Created by Administrator on 14-5-7.
 */

var https  = require('https');
    /**
     * 说明：下列指定了tls.connect()的参数配置说明，然而， globalAgent会忽略掉这些
     * pfx: 证书, 用于SSL的私秘钥证书文件. 默认 null.
    * key: 为SSL提供秘钥. 默认 null.
    * passphrase: 为 私秘钥 或者 pfx提供通行证字符串. 默认 null.
    * cert: 使用公共 x509证书. 默认 null.
    * ca: 权威证书或数组的权威证书检查远程主机.
    * ciphers: A string describing the ciphers to use or exclude. Consult http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT for details on the format.
    * rejectUnauthorized: If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default true.
    * secureProtocol: The SSL method to use, e.g. SSLv3_method to force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constant SSL_METHODS.
    */
    var options = {
        hostname: 'encrypted.google.com',
        port: 443,
        path: '/',
        method: 'GET',
        key: fs.readFileSync('certs/agent2-key.pem'),
        cert: fs.readFileSync('certs/agent2-cert.pem'),
        agent: false
    };

options.agent = new https.Agent(options);
var req = https.request(options ,function(res){
        //do something
    });
req.end();